/*******************************************************************************
 File Name        : freyaactiondataq.h
 Summary          : Data queue of FreyaBaseAction
 Create           : 2023-08-24
 Author           : Schindleren
 Update history   :
 NO.     Author        Date         Content
 001     Schindleren   2023-08-24   Create New
*******************************************************************************/
#ifndef FREYAACTIONDATAQ_H
#define FREYAACTIONDATAQ_H

#include "ringqueue.h"
#include "freyabasedata.h"

#include <QThread>
#include <QQueue>
#include <QEventLoop>

class FreyaBaseAction;
class FreyaActionDataQ : public QThread
{
    Q_OBJECT
public:
    explicit FreyaActionDataQ(FreyaBaseAction *pActObj, const char *SubsysName, bool bIsAsync, int cachesize);
    ~FreyaActionDataQ();

    void ExecuteCache(const FreyaData pData);

private:
    void run();

    inline bool PopData(FreyaData &pData);

private slots:
    void OnExecute(FreyaData pData);

private:
    FreyaBaseAction     *m_pActObj;
    bool                m_bIsAsync;
    QQueue<FreyaData>   m_DataQueue;
    QMutex              m_QueueMutex;
    QEventLoop          *m_ExecEventLoop;
    RingQueue           m_DataRing;
};

#endif // FREYAACTIONDATAQ_H
